package org.bite.controller;

import org.bite.mapper.MessageInfoMapper;
import org.bite.model.MessageInfo;
import org.bite.service.MessageInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;
import java.util.List;

@RequestMapping("/message")
@RestController
public class MessageController {
//    private List<MessageInfo> messageInfoList = new ArrayList<MessageInfo>();

    @Autowired
    private MessageInfoService messageInfoService;

    @RequestMapping(value = "/publish",method = RequestMethod.POST)
    public Boolean publish(@RequestBody MessageInfo messageInfo) {
//        messageInfoList.add(messageInfo);
        messageInfoService.insertMessage(messageInfo);
        return true;

    }

    @RequestMapping("/getList")
    public List<MessageInfo> getList(){
        return messageInfoService.queryMessages();
    }
}
